<?php

namespace app\admin\controller\news;

use app\admin\model\AuthRule;
use app\common\controller\Backend;
use fast\Tree;
use think\Cache;

/**
 * 规则管理
 *
 * @icon fa fa-list
 * @remark 规则通常对应一个控制器的方法,同时左侧的菜单栏数据也从规则中体现,通常建议通过控制台进行生成规则节点
 */
class Home extends Backend
{

    /**
     * @var \app\admin\model\AuthRule
     */
    protected $model = null;
    protected $rulelist = [];
    protected $multiFields = 'ismenu,status';

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * index 页面
     */
    public function index()
    {
        return $this->view->fetch();
    }

    /**
     * Home 页面
     */
    public function formquery()
    {
        $cond = [];
        if($this->request->isPost()){
            $search_param = $this->request->post('row/a');
            //todo:做筛选处理
            $cond = ['wellhead_id'=>$search_param['wellhead']];
        }
        $data = \think\DB::name('wellhead_rate')->where($cond)->select();
        $this->loadlang('news/compare');
        $this->view->assign('rate', $data);
        return $this->view->fetch();
    }

    /**
     * 自定义下拉框
     * @desc fastadmin - 组件：动态下拉列表
     * 使用方法：https://doc.fastadmin.net/docs/component.html#toc-0
     * @return \think\response\Json
     * json(['list'=>[array('id'=>1,'name'=>'option显示文字'),array('id'=>2,'name'=>'option显示文字2')]])
     */
    public function slt_wellhead()
    {
        $data = [
            //id、name 参数名固定，<option value="id">name</option>
            ['id'=>'00100100101','name'=>'井口1'],
            ['id'=>'00100100102','name'=>'井口2']
        ];
        //返回参数固定 list 、total
        return json(['list' => $data, 'total' => 2]);
    }

    /**
     * Home 页面
     */
    public function home()
    {
        return $this->view->fetch();
    }

}
